//公共方法

//碰撞检测
//飞机 obj           敌   子
function crashTest(obj1: HTMLElement, obj2: HTMLElement): boolean {
  //obj1.ele   飞机div 飞机节点
  //水平的位移
  let leftSide = obj1.offsetLeft - obj2.offsetWidth / 2;
  let rightSide = obj1.offsetLeft + obj1.offsetWidth + obj2.offsetWidth / 2;

  let midX = obj2.offsetWidth / 2 + obj2.offsetLeft;
  //垂直方向
  let topSide = obj1.offsetTop - obj2.offsetHeight / 2;
  let bottomSide = obj1.offsetTop + obj1.offsetHeight + obj2.offsetHeight / 2;

  let midY = obj2.offsetHeight / 2 + obj2.offsetTop;

  return leftSide < midX && rightSide > midX && topSide < midY && bottomSide > midY
}

export { crashTest }
